package com.hycat.mail.product.service.impl;

import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hycat.mail.common.utils.PageUtil;
import com.hycat.mail.common.utils.Query;

import com.hycat.mail.product.dao.SkuInfoDao;
import com.hycat.mail.product.entity.SkuInfoEntity;
import com.hycat.mail.product.service.SkuInfoService;


@Service("skuInfoService")
public class SkuInfoServiceImpl extends ServiceImpl<SkuInfoDao, SkuInfoEntity> implements SkuInfoService {

    @Override
    public PageUtil queryPage(Map<String, Object> params) {
        IPage<SkuInfoEntity> page = this.page(
                new Query<SkuInfoEntity>().getPage(params),
                new QueryWrapper<SkuInfoEntity>()
        );

        return new PageUtil(page);
    }

    @Override
    public List<SkuInfoEntity> listBySpuId(Long spuId) {
        QueryWrapper<SkuInfoEntity> wrapper = new QueryWrapper<SkuInfoEntity>().eq("spu_id", spuId);

        return baseMapper.selectList(wrapper);
    }

    @Override
    public SkuInfoEntity getBySkuId(Long skuId) {
        QueryWrapper<SkuInfoEntity> wrapper = new QueryWrapper<SkuInfoEntity>().eq("sku_id", skuId);

        return baseMapper.selectOne(wrapper);
    }

    @Override
    public List<SkuInfoEntity> listBySkuIds(List<Long> skuIds) {
        return baseMapper.selectBatchIds(skuIds);
    }


}